package com.xxkfz.service.impl;

import cn.hutool.core.thread.ThreadUtil;
import com.xxkfz.aspect.lock.RedissonLock;
import com.xxkfz.service.LockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @program: xxkfz-admin-redisson
 * @ClassName LockServiceImpl.java
 * @author: wusongtao
 * @create: 2024-01-19 16:52
 * @description:
 * @Version 1.0
 **/
@Service
@Slf4j
public class LockServiceImpl implements LockService {

    /**
     * 使用自定义分布式锁注解DistributedLock
     *
     * @param param1
     * @return
     */
    @Override
    @RedissonLock(lockKey = "'xxkfz'+ #param1+#param2+#param3", errMsg = "不能重复执行业务逻辑")
    public String execBusinessData(String param1, String param2, Integer param3) {
        log.error("开始执行业务逻辑......");
        ThreadUtil.sleep(20000);
        log.error("param1 = {},param2 = {},param3 = {}", param1, param2, param3);
        log.error("结束执行业务逻辑......");
        return "success";
    }
}